<template>
  <div class="u-page u-box u-text-center u-lh-2 u-pt-50">
    <!-- 图标 -->
    <div>
      <u-icon
        :class="info.type == 'success' ? 'u-cl-primary' : 'u-cl-main'"
        :name="info.type == 'success' ? 'checkmark-circle' : 'info-circle'"
        size="100"
      ></u-icon>
    </div>

    <!-- 标题 -->
    <div
      class="u-fz-20 u-font-bold"
      :class="info.type == 'success' ? 'u-cl-primary' : 'u-cl-main'"
    >
      {{ info.title }}
    </div>

    <!-- 提示 -->
    <div class="u-cl-tips u-mt-15 u-mb-15" v-html="info.tips"></div>

    <!-- 按钮 -->
    <div style="bottom: 100rpx;position: fixed;width: 90%;">
      <div style="margin-top: 40rpx;">
        <u-button type="primary" shape="circle" @click="onClick(info.action)" v-show="!showNormalBut">
          {{ info.btnText }}
        </u-button>
      </div>

      <!-- 关闭按钮 -->
      <div style="margin-top: 40rpx;" v-if="!showCloseBtn">
        <u-button type="info" shape="circle" @click="onClick('toWorkingPlatform')">
          关闭
        </u-button>
      </div>
    </div>

  </div>
</template>

<script>
export default {
  data() {
    return {
      info: {},
      showNormalBut: false, // 普通操作按钮(默认显示)
      showCloseBtn: false, // 关闭按钮(默认显示)
      MainDocUnid: '',// 【主】文档ID
      SubDocUnid: '',// 【子】文档ID
    };
  },

  onLoad(options) {
    let mode =  options.mode;

    // 【主】文档id
    this.MainDocUnid = options.MainDocUnid;

    // 【子】文档ID
    this.SubDocUnid = options.SubDocUnid;

    // 用户发布任务成功的提示
    if(mode == 1){
      this.info = {
		type: "success",
		title: "发布成功！",
		tips: '您的<span style="color:red;">' + options.Subject + '</span>测评任务已发布，平台已自动分配给所有符合条件的拍档，请耐心等待报名信息！<br/>温馨提示：分享给好友或微信群，让更多小伙伴了解您的测评任务哦！',
		btnText: "去分享",
		action: "ShareTask",
      }
    }

    // 拍档提交成果成功后的提示
    if(mode == 2){
      this.showCloseBtn = true;// 隐藏关闭按钮
      this.info = {
        type: "success",
        title: "提交成功！",
        tips: '<span style="color:red;">' + options.Subject + '</span>测评报告已提交，请耐心等待验收。验收通过后，测评报酬将自动发放到您绑定的平台钱包，请注意查收～',
        btnText: "关闭",
        action: "toWorkingPlatform",
      }
    }

    // 用户验收成果成功后的提示
    if(mode == 3){
      this.showCloseBtn = true;// 隐藏关闭按钮
	  let PassNum = parseInt(options.PassNum) + 1
      this.info = {
        type: "success",
        title: "验收成功！",
		tips: '验收结果已发送给<span style="color:red;">' + options.PartnerName + '</span>。<br/><span style="color:red;">' + options.Subject + '</span>的测评任务已验收<span style="color:red;">' + PassNum + '</span>人，等待您的评级！',
        btnText: "关闭",
        action: "toWorkingPlatform",
      }

    }
	
	// 验收不通过(流程回退)的操作通知
	if(mode == 4){
	  this.showCloseBtn = true;// 隐藏关闭按钮
	  this.info = {
	    type: "success",
	    title: "提交成功！",
	    tips: '已成功退回，现在进行<span style="color:red;">第'+ options.ReturnNum + '次</span>修改。',
	    btnText: "关闭",
	    action: "toWorkingPlatform",
	  }
	}
	
	// 验收不通过(回收任务)的操作通知
	if(mode == 5){
	  this.showCloseBtn = true;// 隐藏关闭按钮
	  this.info = {
	    type: "success",
	    title: "任务已回收",
	    tips: '<span style="color:red;">' + options.PartnerName + '</span>参与的<span style="color:red;">' + options.Subject + '</span>测评任务已回收。',
	    btnText: "关闭",
	    action: "toWorkingPlatform",
	  }
	}
	
	
	// 申请积分授权的操作通知
	if(mode == 6){
	  this.showCloseBtn = true;// 隐藏关闭按钮
	  this.info = {
	    type: "success",
	    title: "已发送",
	    tips: '',
	    btnText: "关闭",
	    action: "MyCustomMade",
	  }
	}
	
	
	// 拒绝授权的操作通知
	if(mode == 7){
	  this.showCloseBtn = true;// 隐藏关闭按钮
	  this.info = {
	    type: "success",
	    title: "已发送",
	    tips: '',
	    btnText: "关闭",
	    action: "toWorkingPlatform",
	  }
	}
	
	// 拍档报名参与成功后出现提示
	if(mode == 8){
	  // this.showSubmitBut = true;
	  this.showCloseBtn = true;// 隐藏关闭按钮
	  this.info = {
	    type: "success",
	    title: "已获得测评资格！",
	    tips: '<span style="color:red;">' +options.Subject+'</span>测评任务已开始，请您于<span style="color:red;">' + options.EndTime + '</span>前（含当天）提交测评报告，验收通过后发放本次测评费用！<br/>温馨提示：提交成果时，可点击测评任务列表查看本次要求哦～',
		btnText: "关闭",
		action: "toWorkingPlatform",
	  }
	}

  },

  methods: {
    /**
     * 按钮点击
     */
    onClick(action) {
      switch (action) {
		
        // 工作台
        case "toWorkingPlatform":
		  uni.reLaunch({url:'/pages_tabbar_contact/personal_contact/WorkBench?backto=personalIndex'});
          break;
		  
		// 我的定制
        case "MyCustomMade":
          uni.reLaunch({url:'/pages_private_scene1/Charts/CustomMadeIndex'});
          break;
		
		// 去分享
		case "ShareTask":
		  this.$u.route('/pages_private_scene2/ProductPromote/SignUp?docUnid='+this.MainDocUnid);
		  break;

        default:
          break;
      }
    },

  },
};
</script>

<style lang="scss" scoped></style>
